<%@ page language="java" import="java.util.*" pageEncoding="UTF-8"%>
<%@ taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c" %>
<%
String path = request.getContextPath();
%>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
<link rel="stylesheet" type="text/css" href="<%=path %>/static/css/css.css?1" />
<link rel="stylesheet" type="text/css" href="<%=path %>/static/jquery-ui/jquery-ui.min.css" />
<script type="text/javascript" src="<%=path %>/static/js/json2.js"></script>
<script type="text/javascript" src="<%=path %>/static/js/jquery.js"></script>
<script type="text/javascript" src="<%=path %>/static/jquery-ui/jquery-ui.min.js"></script>
<script type="text/javascript" src="<%=path %>/static/layer/layer.js"></script>
<script type="text/javascript" src="<%=path %>/static/js/gridview.js?v=1"></script>
<script type="text/javascript" src="<%=path %>/static/js/formview.js?v=1"></script>
<script type="text/javascript" src="<%=path %>/static/js/tool.js"></script>
<script type="text/javascript" src="<%=path %>/static/js/validate.js"></script>
</head>

<body style="background:none">
<div id="formview" class="rbox1">
  <div class="rtit2">
     <input type="button" class="btn2" value="返回" style="float:right" onclick="history.go(-1)">
     用户详情
  </div>
  <table width="100%" class="ctable">
   <tbody>
    <tr>
      <td style="width:120px;text-align:right">头像：</td>
      <td uitype="img" name="picUrl"></td>
      <td style="width:120px;text-align:right">昵称：</td>
      <td uitype="text" name="nickName"></td>
    </tr>
    <tr class="tr_space">
          <td align="right">姓名：</td>
          <td uitype="text" name="name"></td>
          <td align="right">会员等级：</td>
          <td uitype="text" name="leav"></td>
    </tr>
    <tr>
      <td style="text-align:right">微信：</td>
      <td uitype="text" name="wechat"></td>
      <td style="text-align:right">支付宝：</td>
      <td uitype="text" name="alipay"></td>
    </tr>
    <tr class="tr_space">
          <td align="right">手机号：</td>
          <td uitype="text" name="mobile"></td>
          <td align="right">性别：</td>
          <td uitype="text" name="sex"></td>
    </tr>
    <tr>
      <td align="right">生日：</td>
      <td uitype="text" name="birthday"></td>
      <td align="right">注册时间：</td>
      <td uitype="text" name="createDateTime"></td>
    </tr>
    <tr class="tr_space">
       <td align="right">来源渠道：</td>
       <td uitype="text" name="srcPla"></td>
       <td align="right">团队人数：</td>
       <td uitype="text" name="teamCnt"></td>
    </tr>
    <tr>
       <td align="right">徒弟：</td>
       <td uitype="text" name="apprentCnt"></td>
       <td align="right">总资金：</td>
       <td uitype="text" name="totalFund"></td>
    </tr>
    <tr class="tr_space">

       <td align="right">钱包余额：</td>
       <td uitype="text" name="availFund"></td>
       <td align="right">任务佣金：</td>
       <td uitype="text" name="taskProfit"></td>
    </tr>
    <tr>

       <td align="right">总返利佣金：</td>
       <td uitype="text" name="rebate"></td>
       <td align="right">分享任务数：</td>
       <td uitype="text" name="taskCnt"></td>
    </tr>
    <tr class="tr_space">

       <td align="right">邀请佣金：</td>
       <td uitype="text" name="inviterProfit"></td>
       <td align="right">继续分享数：</td>
       <td uitype="text" name="contiCnt"></td>
    </tr>
    <tr>
       <td align="right">最后登陆时间：</td>
       <td uitype="text" name="modifyDateTime"></td>
       <td align="right">状态：</td>
       <td uitype="text" name="staval"></td>
    </tr>
   </tbody>
  </table>
</div>
<div id="list" class="rbox2"></div>
<script type="text/javascript" src="<%=path %>/static/js/underscore.js"></script>
<script type='text/javascript' src='<%=path %>/static/My97DatePicker/WdatePicker.js'></script>
<script type='text/javascript' src='<%=path %>/dwr/engine.js'></script>
<script type='text/javascript' src='<%=path %>/dwr/util.js'></script>
<script type='text/javascript' src='<%=path %>/dwr/interface/BaseDwr.js'></script>
<script>
  $.ajaxSetup({
     async: false
  });
  var grid;

  $(function(){
     /*var formSetting = {po:'UserView'};
     var form = new FormView("formview",formSetting);
     form.initview('${param.id}',"UserView");*/

     $.getJSON(g_path+"/public/common/getUserView.htmls",{id:"${param.id}"},function(data){
        var birthday=new Date(data.data.birthday);
        birthday=birthday.Format("yyyy-MM-dd");

        var createDateTime=new Date(data.data.createDateTime);
        createDateTime=createDateTime.Format("yyyy-MM-dd hh:mm");

        var modifyDateTime=new Date(data.data.modifyDateTime);
        modifyDateTime=modifyDateTime.Format("yyyy-MM-dd hh:mm");

        $("td[name=picUrl]").html("<img style='width:100px' src='"+data.data.picUrl+"' />");
        $("td[name=nickName]").text(data.data.nickName);
        $("td[name=name]").text(data.data.name);
        $("td[name=leav]").text(data.data.leav);
        $("td[name=wechat]").text(data.data.wechat);
        $("td[name=alipay]").text(data.data.alipay);
        $("td[name=mobile]").text(data.data.mobile);
        $("td[name=sex]").text(data.data.sex);
        $("td[name=birthday]").text(birthday);
        $("td[name=createDateTime]").text(createDateTime);
        $("td[name=srcPla]").text(data.data.srcPla);
        $("td[name=teamCnt]").text(data.data.teamCnt==null?0:data.data.teamCnt);
        $("td[name=apprentCnt]").text(data.data.apprentCnt==null?0:data.data.apprentCnt);
        $("td[name=totalFund]").text(data.data.totalFund);
        $("td[name=availFund]").text(data.data.availFund);
        $("td[name=taskProfit]").text(data.data.taskProfit==null?0:data.data.taskProfit);
        $("td[name=rebate]").text(data.data.rebate==null?0:data.data.rebate);
        $("td[name=taskCnt]").text(data.data.taskCnt==null?0:data.data.taskCnt);
        $("td[name=inviterProfit]").text(data.data.inviterProfit==null?0:data.data.inviterProfit);
        $("td[name=contiCnt]").text(data.data.contiCnt==null?0:data.data.contiCnt);
        $("td[name=modifyDateTime]").text(modifyDateTime);
        $("td[name=staval]").text(data.data.staval);
     });

     var leav=$("td[name=leav]").text();
     switch(leav){
        case "1":
           $("td[name=leav]").text("一尾狐");
           break;
        case "2":
           $("td[name=leav]").text("二尾狐");
           break;
        case "3":
           $("td[name=leav]").text("三尾狐");
           break;
        case "4":
           $("td[name=leav]").text("四尾狐");
           break;
        case "5":
           $("td[name=leav]").text("五尾狐");
           break;
        case "6":
           $("td[name=leav]").text("六尾狐");
           break;
        case "7":
           $("td[name=leav]").text("七尾狐");
           break;
        case "8":
           $("td[name=leav]").text("八尾狐");
           break;
        case "9":
           $("td[name=leav]").text("九尾狐");
           break;
        default:
           break;
     }
     var srcPla=$("td[name=srcPla]").text();
     if(srcPla=="qf_8"){
        $("td[name=srcPla]").text("应用宝")
     }
     else if(srcPla=="qf_13"){
        $("td[name=srcPla]").text("推啊")
     }
     else if(srcPla=="qf_14"){
        $("td[name=srcPla]").text("任务分享")
     }


    var gridSetting = {
    			id:'QhUserGrid',
    			po:"QhUser",
    			title:'徒弟',
    			height:'auto',
    			service:"uiServices!listSimple",
    			tbId:"UserTb",
    			hideCheckbox:true,
    			pageInfo: {
    				records: 12,//auto表示根据容器高度自动判断
    				orderby : "id desc"
    			},
    			oper:{
                    isDisplay:true,
                	operName:"",
                	url:"",
                	cssClass:"Operation",
                	width:80
                },
    			fields:[
    			   {	name:'id',
    					hide:true
    			   },{
                       name: 'id',
                       descs:"用户ID",
                       align:'center'
                   },
                   {
                       name: 'name',
                       align:'center',
                       descs:"姓名"
                   },
                   {
                       name: 'leav',
                       align:'center',
                       descs:"等级"
                   },
                   {
    				   name: 'mobile',
    				   descs:"手机号",
    				   align:'center'
    			   }
                   ,{
                       name: 'createDateTime',
                       descs:"注册时间",
                       align:'center',
                       type:'datetime'
                   },
                   {
                       name: 'state',
                       descs:"状态",
                       align:'center'
                   }
    			]
    		};
    var data=[];
    data.push({r:"=",name:'inviter',value:$("td[name=mobile]").text()});
    grid = new GridView("list",gridSetting,"list");
    grid.init();
    grid.load({data:data});

  });

  function afterLoad_UserTb(){
         $(".rcon2 .mtable tbody tr").each(function(){
            var id=$(this).attr("recordid");
            var state=$(this).find("td[name=state]").text();

            var html="";
            if(state=="1"){
               $(this).find("td[name=state]").text("正常");
               html+="<a href='javascript:setState("+id+",-1)'>停用</a>";
            }
            else{
               $(this).find("td[name=state]").text("停用");
               html+="<a href='javascript:setState("+id+",1)'>启用</a>";
            }
            $(this).find(".Operation").html(html);

            var $leav=$(this).find("td[name=leav]");

            switch($leav.text()){
               case "1":
                  $leav.text("一尾狐");
                  break;
               case "2":
                  $leav.text("二尾狐");
                  break;
               case "3":
                  $leav.text("三尾狐");
                  break;
               case "4":
                  $leav.text("四尾狐");
                  break;
               case "5":
                  $leav.text("五尾狐");
                  break;
               case "6":
                  $leav.text("六尾狐");
                  break;
               case "7":
                  $leav.text("七尾狐");
                  break;
               case "8":
                  $leav.text("八尾狐");
                  break;
               case "9":
                  $leav.text("九尾狐");
                  break;
               default:
                  break;
            }

         });
  }

  function setState(id,state){
         $.getJSON(g_path+"/public/common/userStateEdit.htmls",{id:id,state:state},function(data){
            layer.alert("操作成功！");
            grid.reload();
         });
      }

</script>
</body>
</html>